import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import "./assets/css/reset.css"
import "./plugins/element.js"
import TreeTable from 'vue-table-with-tree-grid'
//导入进度条插件
import NProgress from 'nprogress'
//导入进度条样式
import 'nprogress/nprogress.css'

//axios的配置
import axios from "axios"
axios.defaults.baseURL="https://www.liulongbin.top:8888/api/private/v1/"


//富文本编辑器使用
import VueQuillEditor from 'vue-quill-editor'

// 编辑器样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

Vue.use(VueQuillEditor)
Vue.prototype.$http=axios;

//将token设置头请求头上
axios.interceptors.request.use(
  config=>{
    //摄制请求拦截器给我们请求头设置token
    var arr = JSON.parse(sessionStorage.getItem("loginmsg"));
    var token;
    if(arr){
      token = arr.token
    }else{
      token = null
    }
      //当进入request拦截器，表示发送了请求，我们就开启进度条
  NProgress.start()
    // console.log(token)
    config.headers.Authorization=token;
    return config;
  }
)
//在response拦截器中，隐藏进度条
axios.interceptors.response.use(config =>{
  //当进入response拦截器，表示请求已经结束，我们就结束进度条
  NProgress.done()
  return config
})
//将axios挂载到vue的原型上
 
Vue.config.productionTip = false
 //全局注册组件
 Vue.component('tree-table', TreeTable)
 
new Vue({
  router,
  store,  
  render: h => h(App)
}).$mount('#app')
 